package org.jeecg.modules.bobo.wechat.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.bobo.wechat.common.entity.WechatOrders;
import org.jeecg.modules.bobo.wechat.common.mapper.WechatOrdersMapper;
import org.jeecg.modules.bobo.wechat.common.service.IWechatOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 订单记录
 * @Author: jeecg-boot
 * @Date:   2020-11-23
 * @Version: V1.0
 */
@Service
public class WechatOrdersServiceImpl extends ServiceImpl<WechatOrdersMapper, WechatOrders> implements IWechatOrdersService {
    @Autowired
    private WechatOrdersMapper wechatOrdersMapper;

    @Override
    public List<WechatOrders> selectByOpenId(String openId) {
        return wechatOrdersMapper.selectByOpenId(openId);
    }

    @Override
    public WechatOrders getOneByOutTradeNo(String outTradeNo) {
        return getOne(new QueryWrapper<WechatOrders>().lambda().eq(WechatOrders::getOutTradeNo,outTradeNo));
    }

    @Override
    public boolean UpdateByOutTradeNo(WechatOrders wechatOrders) {
        return update(wechatOrders, new UpdateWrapper<WechatOrders>().lambda().eq(WechatOrders::getOutTradeNo,wechatOrders.getOutTradeNo()));
    }
}
